package com.wanshu.service.impl;

import com.wanshu.dao.OrderDao;
import com.wanshu.entity.Order;
import com.wanshu.entity.vo.ShopOrder;
import com.wanshu.service.OrderService;

import javax.annotation.Resource;
import java.util.List;

public class OrderServiceImpl implements OrderService {

    @Resource
    private OrderDao orderDao;

    public void setOrderDao(OrderDao orderDao) {
        this.orderDao = orderDao;
    }

    public String submitOrder(Order order){
        Integer update = orderDao.update(order);
        String msg = "提交失败";
        if(update > 0){
            msg = "提交成功!";
        }
        return msg;
    }

    public List<Order> findAll(){
        return orderDao.findAll();
    }

    public Order findById(Integer id){
        return orderDao.findById(id);
    }

    @Override
    public Integer insert(Order order) {
        return orderDao.insert(order);
    }

    @Override
    public List<ShopOrder> selectByUserId(Integer userId) {
        return orderDao.selectByUserId(userId);
    }
}
